home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / 1APJCFJ (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  1.8 KB  |  31 lines

  1. package com.ibm.uvm.abt.edit;
  2.  
  3. import java.beans.PropertyEditorSupport;
  4. import java.util.ResourceBundle;
  5.  
  6. public class CharEditor extends PropertyEditorSupport {
  7.    private static ResourceBundle resabtedit = ResourceBundle.getBundle("com/ibm/uvm/abt/edit/abtedit");
  8.  
  9.    public String getAsText() {
  10.       if (((PropertyEditorSupport)this).getValue() == null) {
  11.          return "";
  12.       } else {
  13.          Character v = (Character)((PropertyEditorSupport)this).getValue();
  14.          return v.toString();
  15.       }
  16.    }
  17.  
  18.    public String getJavaInitializationString() {
  19.       Character c = (Character)((PropertyEditorSupport)this).getValue();
  20.       return c != '\\' && c != '\'' ? "'" + c + "'" : "'\\" + c + "'";
  21.    }
  22.  
  23.    public void setAsText(String text) throws IllegalArgumentException {
  24.       if (text.length() == 1) {
  25.          ((PropertyEditorSupport)this).setValue(new Character(text.charAt(0)));
  26.       } else {
  27.          throw new IllegalArgumentException(resabtedit.getString("Invalid_property_value") + text + resabtedit.getString("entered_for_a_char"));
  28.       }
  29.    }
  30. }
  31.